home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2207 / 2207.xpi / chrome / cooliris.jar / content / cooliris / utils.js < prev    next >
Text File  |  2010-01-28  |  44KB  |  1,204 lines

  1. function cpvw_WebResponse(_1,_2){
  2. this.eId=_1;
  3. this.eMesg=_2;
  4. this.results=null;
  5. this.auxObj=null;
  6. this.headers=null;
  7. function SetError(_3,_4){
  8. this.eId=_3;
  9. this.eMesg=_4;
  10. }
  11. }
  12. if(typeof cpvw_Prefs=="undefined"){
  13. var cpvw_Prefs={prefPreviewSize:"preview.size",prefPreviewEnable:"preview.enable",prefPreviewPrefetch:"preview.prefetch",prefPreviewEmailFrom:"preview.emailfrom",prefPreviewEmailTo:"preview.emailto",prefPreviewDefaultEnable:"preview.defaultenable",prefPreviewUserEmail:"preview.useremail",prefPreviewDebug:"preview.debug",prefPreviewIsNew:"preview.isnew",prefPreviewOpenMode:"preview.previewopenmode",prefPreviewOpenDelay:"preview.previewopendelay",prefMouseIconDelay:"preview.mouseIconDelay",prefPreviewOnIconDelay:"preview.previewOnIconDelay",prefHidePreviewDelay:"preview.hidePreviewDelay",prefPreviewLoc:"preview.location",prefPreviewFixedLoc:"preview.fixedlocation",prefFixedIcon:"preview.fixedMouseoverIcon",prefCMenuItems:"preview.contextMenuItems",prefTextZoom:"preview.textZoom",prefTheme:"preview.theme",prefGUID:"preview.GUID",prefTimestamp:"preview.timestamp",prefCount:"preview.previewcount",prefPiclensFilterSize:"preview.piclensFilterSize",prefInstallTS:"preview.install_timestamp",prefLastUpdateTS:"preview.last_update_timestamp",prefInlineSubsearch:"preview.inlineSubsearch",prefSubsearchBar:"preview.subsearchBar",prefAdId:"preview.adId",prefUserType:"preview.userType",prefAdPingInterval:"preview.adPingInterval",prefAdUpdateTime:"preview.adUpdateTime",prefAdPrefJson:"preview.adPrefJson",prefShowHelperFrame:"preview.showHelperFrame",prefLock:"preview.lock",prefQuickSearch:"preview.quickSearchPreferences",jsonPrefCooliris:"preview.cooliris",jsonPrefZoom:"preview.zoom",populatePreviewBarDropDown:function(_5){
  14. while(cpvw_get("cpvw_bar_sites",_5).length>0){
  15. cpvw_get("cpvw_bar_sites",_5).remove(0);
  16. }
  17. var _6=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  18. var _7=_6.split(",");
  19. if(cpvw_contextSitesTreeView.arrCMenuItems==null){
  20. cpvw_contextSitesTreeView.loadContextSites();
  21. }
  22. var _8="";
  23. for(var _9 in cpvw_contextSitesTreeView.arrCMenuItems){
  24. _8+=_9+", ";
  25. }
  26. for(var i=0;i<_7.length;i++){
  27. if(cpvw_contextSitesTreeView.arrCMenuItems[_7[i]]!=null){
  28. var _b=_5.createElement("option");
  29. _b.text=cpvw_contextSitesTreeView.arrCMenuItems[_7[i]].label;
  30. _b.value=i;
  31. cpvw_get("cpvw_bar_sites",_5).add(_b,null);
  32. }
  33. }
  34. },setCMenuItems:function(){
  35. while(cpvw_get("coolirisSearchPopup").childNodes.length>0){
  36. cpvw_get("coolirisSearchPopup").removeChild(cpvw_get("coolirisSearchPopup").firstChild);
  37. }
  38. var _c=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  39. var _d=_c.split(",");
  40. if(cpvw_contextSitesTreeView.arrCMenuItems==null){
  41. cpvw_contextSitesTreeView.loadContextSites();
  42. }
  43. var _e="";
  44. for(var _f in cpvw_contextSitesTreeView.arrCMenuItems){
  45. _e+=_f+", ";
  46. }
  47. for(var i=0;i<_d.length;i++){
  48. if(cpvw_contextSitesTreeView.arrCMenuItems[_d[i]]!=null){
  49. if(_d[i]=="cooliris"&&!cpvw_jsUtils.hasCooliris()){
  50. continue;
  51. }
  52. var _11=document.createElement("menuitem");
  53. _11.setAttribute("label",cpvw_contextSitesTreeView.arrCMenuItems[_d[i]].label);
  54. _11.setAttribute("image",cpvw_contextSitesTreeView.arrCMenuItems[_d[i]].image);
  55. _11.setAttribute("value",i);
  56. _11.setAttribute("class","menuitem-iconic");
  57. _11.addEventListener("command",function(evt){
  58. cpvw_objContextMenu.initPreviewShow(this,"click",evt);
  59. },false);
  60. _11.addEventListener("mouseover",function(evt){
  61. cpvw_objContextMenu.initPreviewShow(this);
  62. },false);
  63. _11.addEventListener("mouseout",function(evt){
  64. cpvw_objContextMenu.initPreviewHide();
  65. },false);
  66. cpvw_get("coolirisSearchPopup").appendChild(_11);
  67. }
  68. }
  69. _11=document.createElement("menuitem");
  70. _11.setAttribute("label","Add more >>");
  71. _11.setAttribute("value",i);
  72. _11.setAttribute("class","menuitem-iconic");
  73. _11.addEventListener("command",function(evt){
  74. cpvw_Prefs.showPrefDialog(evt,true);
  75. },false);
  76. cpvw_get("coolirisSearchPopup").appendChild(_11);
  77. },setSendToEmail:function(to){
  78. cpvw_prefHandler.setPref(this.prefPreviewEmailTo,to);
  79. },defaultEnable:function(){
  80. var _17=cpvw_prefHandler.getPref(this.prefPreviewDefaultEnable);
  81. var _18;
  82. if(_17=="yes"){
  83. cpvw_prefHandler.setPref(this.prefPreviewDefaultEnable,"no");
  84. _18="Default Enable is now Off. This means that Cooliris Previews will now work only on the sites \n selected by Cooliris along with the ones that you have enabled explicitly";
  85. }else{
  86. cpvw_prefHandler.setPref(this.prefPreviewDefaultEnable,"yes");
  87. _18="Default Enable is now On. This means that Cooliris Previews will now work for all sites \n on the world wide web except for the ones you have disabled explicitly.";
  88. }
  89. alert(_18);
  90. },getSendToEmail:function(){
  91. var to="";
  92. if(cpvw_prefHandler.isExists(this.prefPreviewEmailTo)){
  93. to=cpvw_prefHandler.getPref(this.prefPreviewEmailTo);
  94. }
  95. return to;
  96. },togglePreviewSite:function(){
  97. var _1a=cpvw_objOverlay.getContentDocument();
  98. var url=_1a.location.href;
  99. var _1c="yes";
  100. var _1d=cpvw_siteManager.isIncludedSite(url);
  101. if(_1d[0]){
  102. _1c="no";
  103. }
  104. var _1e=cpvw_prefHandler.getPref(this.prefPreviewEnable);
  105. if(_1e=="no"){
  106. _1c="yes";
  107. }
  108. cpvw_siteManager.editSite(url,_1c);
  109. if(_1c=="yes"){
  110. document.getElementById("preview-status-image").src="chrome://cooliris/skin/new/previews-on.png";
  111. cpvw_get("preview-status").setAttribute("status","previewsOnSite");
  112. var _1a=cpvw_objOverlay.getContentDocument();
  113. cpvw_objOverlay.changeLinks(_1a);
  114. if(cpvw_docHandler){
  115. cpvw_docHandler.parentDoc.enablePreview=true;
  116. }
  117. if(cpvw_imageDocHandler){
  118. cpvw_imageDocHandler.parentDoc.enablePreview=true;
  119. }
  120. }else{
  121. if(cpvw_imageDocHandler){
  122. cpvw_imageDocHandler.parentDoc.enablePreview=false;
  123. }
  124. if(cpvw_docHandler){
  125. cpvw_docHandler.parentDoc.enablePreview=false;
  126. }
  127. document.getElementById("preview-status-image").src="chrome://cooliris/skin/new/previews-off.png";
  128. cpvw_get("preview-status").setAttribute("status","previewsOffSite");
  129. }
  130. cpvw_prefHandler.setPref(this.prefPreviewEnable,"yes");
  131. },showPrefDialog:function(evt,_20){
  132. cpvw_objStats.sendButtonClickEvents("Preferences");
  133. if(!cpvw_jsUtils.isFF2()){
  134. window.openDialog("chrome://cooliris/content/options3.xul","Cooliris Options","chrome,centerscreen,modal",_20);
  135. }else{
  136. window.openDialog("chrome://cooliris/content/options.xul","Cooliris Options","chrome,centerscreen,modal",_20);
  137. }
  138. cpvw_previewHandler.setThemeToolbar();
  139. cpvw_contextSitesTreeView.arrCMenuItems=null;
  140. cpvw_previewHandler.previewOpenMode=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewOpenMode);
  141. if(cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewEnable)=="no"){
  142. document.getElementById("preview-status-image").src="chrome://cooliris/skin/new/globaloff.png";
  143. cpvw_get("preview-status").setAttribute("status","globaloff");
  144. }else{
  145. cpvw_objOverlay.changeLinks(cpvw_objOverlay.getContentDocument());
  146. }
  147. var _21=cpvw_prefHandler.getPref(this.prefPreviewOpenDelay);
  148. cpvw_Delays.DISPLAY_DELAY_TIME=_21;
  149. if(_21-500<=100){
  150. cpvw_Delays.OPEN_DELAY_TIME=100;
  151. }else{
  152. cpvw_Delays.OPEN_DELAY_TIME=_21-500;
  153. }
  154. cpvw_Delays.ICON_DELAY_TIME=cpvw_prefHandler.getPref(this.prefMouseIconDelay);
  155. cpvw_Delays.PREVIEW_ON_ICON_DELAY=_21;
  156. cpvw_Delays.CLOSE_DELAY_TIME=parseInt(cpvw_prefHandler.getPref(this.prefHidePreviewDelay),10);
  157. },togglePreviewTip:function(){
  158. var _22=cpvw_prefHandler.getPref(this.prefPreviewEnable);
  159. if(_22=="yes"){
  160. cpvw_prefHandler.setPref(this.prefPreviewEnable,"no");
  161. }else{
  162. cpvw_prefHandler.setPref(this.prefPreviewEnable,"yes");
  163. var _23=cpvw_objOverlay.getContentDocument();
  164. cpvw_objOverlay.changeLinks(_23);
  165. }
  166. this.getPreferences();
  167. },showStatusMenu:function(){
  168. var _24=cpvw_get("cooliris_status_menu");
  169. while(_24.childNodes.length>0){
  170. _24.removeChild(_24.firstChild);
  171. }
  172. var _25=cpvw_get("preview-status");
  173. var _26=document.createElement("menuitem");
  174. _26.setAttribute("label","User Preferences");
  175. _26.setAttribute("image","chrome://cooliris/skin/new/preferences.png");
  176. _26.setAttribute("class","menuitem-iconic");
  177. _26.addEventListener("command",function(evt){
  178. cpvw_Prefs.showPrefDialog(evt);
  179. },false);
  180. _24.appendChild(_26);
  181. var _28=cpvw_prefHandler.getPref(this.prefPreviewEnable);
  182. switch(_25.getAttribute("status")){
  183. case "previewsOnSite":
  184. var _26=document.createElement("menuitem");
  185. _26.setAttribute("label","Disable Completely");
  186. _26.setAttribute("image","chrome://cooliris/skin/new/coolpreviews-disabled.png");
  187. _26.setAttribute("class","menuitem-iconic");
  188. _26.addEventListener("command",function(evt){
  189. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewEnable,"no");
  190. cpvw_Prefs.getPreferences();
  191. },false);
  192. _24.appendChild(_26);
  193. _26=document.createElement("menuseparator");
  194. _24.appendChild(_26);
  195. _26=document.createElement("menuitem");
  196. _26.setAttribute("label","Disable CoolPreviews on this site");
  197. _26.setAttribute("image","chrome://cooliris/skin/new/coolpreviews-disabled-for-site.png");
  198. _26.setAttribute("class","menuitem-iconic");
  199. _26.addEventListener("command",function(evt){
  200. cpvw_Prefs.togglePreviewSite();
  201. cpvw_objOverlay.changeLinks();
  202. },false);
  203. _24.appendChild(_26);
  204. break;
  205. case "previewsOffSite":
  206. var _26=document.createElement("menuitem");
  207. _26.setAttribute("label","Disable Completely");
  208. _26.setAttribute("image","chrome://cooliris/skin/new/coolpreviews-disabled.png");
  209. _26.setAttribute("class","menuitem-iconic");
  210. _26.addEventListener("command",function(evt){
  211. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewEnable,"no");
  212. cpvw_Prefs.getPreferences();
  213. },false);
  214. _24.appendChild(_26);
  215. _26=document.createElement("menuseparator");
  216. _24.appendChild(_26);
  217. _26=document.createElement("menuitem");
  218. _26.setAttribute("label","Enable CoolPreviews on this site");
  219. _26.setAttribute("image","chrome://cooliris/skin/new/coolpreviews-enabled.png");
  220. _26.setAttribute("class","menuitem-iconic");
  221. _26.addEventListener("command",function(evt){
  222. cpvw_Prefs.togglePreviewSite();
  223. cpvw_objOverlay.changeLinks();
  224. },false);
  225. _24.appendChild(_26);
  226. break;
  227. case "globaloff":
  228. _26=document.createElement("menuseparator");
  229. _24.appendChild(_26);
  230. var _26=document.createElement("menuitem");
  231. _26.setAttribute("label","Enable CoolPreviews");
  232. _26.setAttribute("image","chrome://cooliris/skin/new/coolpreviews-enabled.png");
  233. _26.setAttribute("class","menuitem-iconic");
  234. _26.addEventListener("command",function(evt){
  235. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewEnable,"yes");
  236. cpvw_objOverlay.changeLinks();
  237. },false);
  238. _24.appendChild(_26);
  239. break;
  240. }
  241. if(!cpvw_jsUtils.isFF2()){
  242. _24.openPopup(_25,"before_start",0,0,false,false);
  243. }else{
  244. _24.showPopup(_25,-1,-1,"popup","bottomleft","topleft");
  245. }
  246. },setPreviewSize:function(_2e,_2f){
  247. cpvw_prefHandler.setPref(this.prefPreviewSize,_2e+","+_2f);
  248. },setPreviewLoc:function(_30,top){
  249. try{
  250. top=parseInt(top);
  251. if(top==0||top<0){
  252. throw "less than zero";
  253. }
  254. }
  255. catch(ex){
  256. top=120;
  257. }
  258. cpvw_prefHandler.setPref(this.prefPreviewLoc,_30+","+top);
  259. },setZoomPref:function(_32){
  260. _32=_32||{zoomType:"full",zoomSetting:"previews",zoomFullSize:0.8,zoomTextSize:1};
  261. cpvw_prefHandler.setPrefJson(this.jsonPrefZoom,_32);
  262. },initPreferences:function(){
  263. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewSize,"760,480");
  264. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewEnable,"yes");
  265. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewPrefetch,"no");
  266. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewDefaultEnable,"yes");
  267. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewDebug,"no");
  268. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewOpenMode,"icon");
  269. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewOpenDelay,500);
  270. cpvw_prefHandler.setPrefIfNotExists(this.prefMouseIconDelay,500);
  271. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewOnIconDelay,500);
  272. cpvw_prefHandler.setPrefIfNotExists(this.prefHidePreviewDelay,1000);
  273. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewFixedLoc,"yes");
  274. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewLoc,"200,200");
  275. if(!cpvw_prefHandler.getPref(this.jsonPrefZoom)){
  276. this.setZoomPref(null);
  277. }
  278. cpvw_prefHandler.setPrefIfNotExists(this.prefShowHelperFrame,true);
  279. cpvw_prefHandler.setPrefIfNotExists(this.prefAdPingInterval,3600000);
  280. cpvw_prefHandler.setPrefIfNotExists(this.prefLock,false);
  281. cpvw_prefHandler.setPrefIfNotExists(this.prefFixedIcon,true);
  282. cpvw_prefHandler.setPrefIfNotExists(this.prefTheme,"default");
  283. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewIsNew,"0");
  284. cpvw_prefHandler.setPrefIfNotExists(this.prefPiclensFilterSize,"50,50");
  285. cpvw_prefHandler.setPrefIfNotExists(this.prefPreviewUserEmail,"");
  286. var _33=cpvw_prefHandler.getPref(this.prefPreviewOpenDelay);
  287. cpvw_prefHandler.setPrefIfNotExists(this.prefCMenuItems,"cooliris,googlesearch,twitter,youtube,wiki,dictionary,googleimages,amazonsearch,bingsearch");
  288. cpvw_prefHandler.setPrefIfNotExists(this.prefSubsearchBar,true);
  289. var ts=Math.round((new Date()).getTime()/1000);
  290. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefInstallTS,ts);
  291. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefLastUpdateTS,ts);
  292. var _35=Math.ceil((Math.random()*1000));
  293. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefAdId,_35);
  294. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefUserType,"new");
  295. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefUserType,"new");
  296. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefAdUpdateTime,Math.round((new Date()).getTime()/1000));
  297. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefAdPrefJson,"{}");
  298. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.prefQuickSearch,"{\"searchPhrase\" : \"\", \"lastUsedWebsite\":0}");
  299. cpvw_prefHandler.setPrefIfNotExists(cpvw_Prefs.jsonPrefCooliris,"{\"showCoolirisPage\" : true}");
  300. cpvw_Delays.DISPLAY_DELAY_TIME=_33;
  301. cpvw_Delays.OPEN_DELAY_TIME=_33-500;
  302. cpvw_Delays.ICON_DELAY_TIME=cpvw_prefHandler.getPref(this.prefMouseIconDelay);
  303. cpvw_Delays.PREVIEW_ON_ICON_DELAY=_33;
  304. cpvw_Delays.CLOSE_DELAY_TIME=parseInt(cpvw_prefHandler.getPref(this.prefHidePreviewDelay),10);
  305. this.getPreferences();
  306. },getPreferences:function(){
  307. var _36=cpvw_prefHandler.getPref(this.prefPreviewEnable);
  308. if(_36=="no"){
  309. document.getElementById("preview-status-image").src="chrome://cooliris/skin/new/globaloff.png";
  310. cpvw_get("preview-status").setAttribute("status","globaloff");
  311. cpvw_objOverlay.removeLinks();
  312. }
  313. },loadOptionsPreviewPrefs:function(){
  314. var _37=(window.arguments&&window.arguments[0])||false;
  315. if(cpvw_jsUtils.isFF2()){
  316. window.openDialog("chrome://cooliris/content/options.xul","Cooliris Options","chrome,centerscreen,modal",_37);
  317. window.close();
  318. }
  319. var _38=cpvw_prefHandler.getPref(this.prefPreviewPrefetch);
  320. var _39=cpvw_prefHandler.getPref(this.prefPreviewEnable);
  321. var _3a=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewFixedLoc);
  322. var _3b=cpvw_prefHandler.getPref(this.prefPreviewDefaultEnable);
  323. var _3c=cpvw_prefHandler.getPref(cpvw_Prefs.prefFixedIcon);
  324. if(_39=="no"){
  325. document.getElementById("cooliris_globalDisable").selectedIndex=1;
  326. }else{
  327. document.getElementById("cooliris_globalDisable").selectedIndex=0;
  328. }
  329. var _3d=cpvw_prefHandler.getPref(this.prefSubsearchBar);
  330. cpvw_get("cpvw_quicksearch").selectedIndex=_3d?0:1;
  331. var _3e=cpvw_prefHandler.getPref(cpvw_Prefs.prefTheme);
  332. cpvw_get("cpvw_theme").selectedIndex=(_3e=="default")?0:1;
  333. document.getElementById("cooliris_fixedLoc").setAttribute("checked",(_3a=="yes"));
  334. var _3f=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewOpenMode);
  335. cpvw_get("cooliris_previewOpenMode").value=_3f;
  336. cpvw_get("cooliris_fixedIcon").selectedIndex=_3c?0:1;
  337. var _40=parseInt(cpvw_prefHandler.getPref(cpvw_Prefs.prefMouseIconDelay),10);
  338. cpvw_get("scaleIcon").value=10-Math.ceil(_40/250);
  339. var _41=parseInt(cpvw_prefHandler.getPref(this.prefPreviewOpenDelay),10);
  340. cpvw_get("scaleOpenPreview").value=10-Math.ceil(_41/250);
  341. var _42=parseInt(cpvw_prefHandler.getPref(this.prefHidePreviewDelay),10);
  342. cpvw_get("scaleClosePreview").value=10-(Math.ceil(_42/250)-2);
  343. var _43=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  344. _43=","+_43+",";
  345. cpvw_contextSitesTreeView.loadContextSites();
  346. cpvw_get("cooliris_contextSiteTree").view=cpvw_contextSitesTreeView;
  347. cpvw_get("cooliris_contextSiteTreeSelected").view=cpvw_contextSitesTreeViewSelected;
  348. cpvw_contextSitesTreeView.invalidateTree(0,cpvw_contextSitesTreeView.arrSites.length);
  349. cpvw_contextSitesTreeViewSelected.invalidateTree(0,cpvw_contextSitesTreeViewSelected.arrSites.length);
  350. if(_37){
  351. cpvw_get("cpvw_tabBox").selectedIndex=1;
  352. }
  353. },onSliderChange:function(_44){
  354. switch(_44){
  355. case "icon":
  356. cpvw_get("labelIcon").value=((10-cpvw_get("scaleIcon").value)*250)+" msec";
  357. break;
  358. case "previewOpen":
  359. cpvw_get("labelOpenPreview").value=((10-cpvw_get("scaleOpenPreview").value)*250)+" msec";
  360. break;
  361. case "previewClose":
  362. cpvw_get("labelClosePreview").value=((10-cpvw_get("scaleClosePreview").value)*250)+" msec";
  363. break;
  364. }
  365. },getOptionsPreviewPrefs:function(){
  366. var _45=window.arguments[0];
  367. var _46=cpvw_prefHandler.getPref(this.prefPreviewPrefetch);
  368. var _47=cpvw_prefHandler.getPref(this.prefPreviewEnable);
  369. var _48=cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewFixedLoc);
  370. var _49=cpvw_prefHandler.getPref(this.prefPreviewDefaultEnable);
  371. var _4a=cpvw_prefHandler.getPref(cpvw_Prefs.prefFixedIcon);
  372. document.getElementById("cooliris_globalDisable").setAttribute("checked",(_47=="no")?true:false);
  373. document.getElementById("cooliris_defaultEnable").setAttribute("checked",(_49=="yes")?true:false);
  374. document.getElementById("cooliris_prefetchWebsites").setAttribute("checked",(_46=="yes")?true:false);
  375. document.getElementById("cooliris_fixedLoc").setAttribute("checked",(_48=="yes")?false:true);
  376. document.getElementById("cooliris_fixedIcon").setAttribute("checked",(_4a)?true:false);
  377. var _4b=cpvw_prefHandler.getPref(this.prefPreviewOpenDelay);
  378. document.getElementById("cooliris_openDelay").value=_4b;
  379. document.getElementById("cooliris_smallDivDelay").value=cpvw_prefHandler.getPref(this.prefMouseIconDelay);
  380. document.getElementById("cooliris_hidePreviewDelay").value=cpvw_prefHandler.getPref(this.prefHidePreviewDelay);
  381. var _4c=cpvw_prefHandler.getPref(this.prefPreviewOpenMode);
  382. document.getElementById("cooliris_previewOpenMode").value=_4c;
  383. var _4d=cpvw_prefHandler.getPref(cpvw_Prefs.prefTheme);
  384. cpvw_get("cooliris_previewTheme").value=_4d;
  385. var _4e=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  386. _4e=","+_4e+",";
  387. cpvw_contextSitesTreeView.loadContextSites();
  388. cpvw_get("cooliris_contextSiteTree").view=cpvw_contextSitesTreeView;
  389. cpvw_get("cooliris_contextSiteTreeSelected").view=cpvw_contextSitesTreeViewSelected;
  390. for(var key in cpvw_contextSitesTreeView.arrCMenuItems){
  391. if(_4e.indexOf(","+key+",")!=-1){
  392. cpvw_contextSitesTreeViewSelected.arrSites.push(key);
  393. cpvw_contextSitesTreeView.arrCMenuItems[key].selected=true;
  394. }else{
  395. cpvw_contextSitesTreeView.arrSites.push(key);
  396. cpvw_contextSitesTreeView.arrCMenuItems[key].selected=false;
  397. }
  398. }
  399. cpvw_contextSitesTreeViewSelected.arrSites.sort(function(a,b){
  400. if(_4e.indexOf(a)<_4e.indexOf(b)){
  401. return -1;
  402. }else{
  403. if(_4e.indexOf(a)>_4e.indexOf(b)){
  404. return 1;
  405. }
  406. }
  407. return 0;
  408. });
  409. cpvw_contextSitesTreeView.arrSites.sort();
  410. cpvw_contextSitesTreeView.invalidateTree(0,cpvw_contextSitesTreeView.arrSites.length);
  411. cpvw_contextSitesTreeViewSelected.invalidateTree(0,cpvw_contextSitesTreeViewSelected.arrSites.length);
  412. var _52=cpvw_prefHandler.getPref(this.prefSubsearchBar);
  413. cpvw_get("cooliris_subsearchBar").checked=_52;
  414. if(_45){
  415. cpvw_get("cpvw_tabBox").selectedIndex=1;
  416. }
  417. },managePiclensFilter:function(){
  418. if(cpvw_get("cooliris_piclensFilter").checked){
  419. cpvw_get("cooliris_piclens_width").disabled=false;
  420. cpvw_get("cooliris_piclens_height").disabled=false;
  421. var _53=cpvw_prefHandler.getPref(cpvw_Prefs.prefPiclensFilterSize);
  422. if(_53!=""){
  423. var _54=_53.split(",");
  424. cpvw_get("cooliris_piclens_width").value=_54[0];
  425. cpvw_get("cooliris_piclens_height").value=_54[1];
  426. }else{
  427. cpvw_get("cooliris_piclens_width").value=50;
  428. cpvw_get("cooliris_piclens_height").value=50;
  429. }
  430. }else{
  431. cpvw_get("cooliris_piclens_width").disabled=true;
  432. cpvw_get("cooliris_piclens_height").disabled=true;
  433. }
  434. },restoreDefaults:function(){
  435. cpvw_prefHandler.setPref(this.prefPreviewSize,"760,480");
  436. cpvw_prefHandler.setPref(this.prefPreviewEnable,"yes");
  437. cpvw_prefHandler.setPref(this.prefPreviewPrefetch,"no");
  438. cpvw_prefHandler.setPref(this.prefPreviewDefaultEnable,"yes");
  439. cpvw_prefHandler.setPref(this.prefPreviewDebug,"no");
  440. cpvw_prefHandler.setPref(this.prefPreviewOpenMode,"icon");
  441. cpvw_prefHandler.setPref(this.prefPreviewOpenDelay,"500");
  442. cpvw_prefHandler.setPref(this.prefMouseIconDelay,"500");
  443. cpvw_prefHandler.setPref(this.prefPreviewOnIconDelay,"500");
  444. cpvw_prefHandler.setPref(this.prefHidePreviewDelay,"1000");
  445. cpvw_prefHandler.setPref(this.prefPreviewFixedLoc,"yes");
  446. cpvw_prefHandler.setPref(this.prefPreviewLoc,"200,200");
  447. this.setZoomPref(null);
  448. cpvw_prefHandler.setPref(this.prefLock,false);
  449. cpvw_prefHandler.setPref(this.prefFixedIcon,true);
  450. cpvw_prefHandler.setPref(this.prefTheme,"default");
  451. cpvw_prefHandler.setPref(this.prefSubsearchBar,true);
  452. cpvw_contextSitesTreeView.invalidateTree(0,-cpvw_contextSitesTreeView.arrSites.length);
  453. cpvw_contextSitesTreeViewSelected.invalidateTree(0,-cpvw_contextSitesTreeViewSelected.arrSites.length);
  454. cpvw_contextSitesTreeViewSelected.arrSites=[];
  455. cpvw_contextSitesTreeView.arrSites=[];
  456. cpvw_prefHandler.setPref(this.prefCMenuItems,"cooliris,googlesearch,twitter,bingsearch,wiki,youtube,amazonsearch,tfd,hulu,googlefinance,googleimages");
  457. if(cpvw_jsUtils.isFF2()){
  458. this.getOptionsPreviewPrefs();
  459. }else{
  460. this.loadOptionsPreviewPrefs();
  461. }
  462. var _55=cpvw_jsUtils.getWorkingFolder();
  463. _55.append(cpvw_siteManager.xmlSiteFile);
  464. _55.remove(false);
  465. var _56=cpvw_jsUtils.getWorkingFolder();
  466. _56.append(cpvw_contextSitesTreeView.jsContextSiteFile);
  467. _56.remove(false);
  468. },doOKNew:function(){
  469. var _57=(document.getElementById("cooliris_globalDisable").selectedIndex==1);
  470. if(_57){
  471. cpvw_prefHandler.setPref(this.prefPreviewEnable,"no");
  472. if(window.opener&&window.opener.cpvw_objOverlay&&window.opener.cpvw_objOverlay.removeLinks){
  473. window.opener.cpvw_objOverlay.removeLinks();
  474. }
  475. }else{
  476. cpvw_prefHandler.setPref(this.prefPreviewEnable,"yes");
  477. if(window.opener&&window.opener.cpvw_objOverlay&&window.opener.cpvw_objOverlay.changeLinks){
  478. window.opener.cpvw_objOverlay.changeLinks();
  479. }
  480. }
  481. var _58=document.getElementById("cooliris_fixedLoc").checked;
  482. if(_58){
  483. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewFixedLoc,"yes");
  484. }else{
  485. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewFixedLoc,"no");
  486. }
  487. var _59=(document.getElementById("cooliris_fixedIcon").selectedIndex==0);
  488. if(_59){
  489. cpvw_prefHandler.setPref(cpvw_Prefs.prefFixedIcon,true);
  490. }else{
  491. cpvw_prefHandler.setPref(cpvw_Prefs.prefFixedIcon,false);
  492. }
  493. var _5a=(10-parseInt(document.getElementById("scaleOpenPreview").value,10))*250;
  494. cpvw_prefHandler.setPref(this.prefPreviewOpenDelay,_5a);
  495. var _5b=(10-parseInt(document.getElementById("scaleIcon").value,10))*250;
  496. cpvw_prefHandler.setPref(this.prefMouseIconDelay,_5b);
  497. var _5c=500+(10-parseInt(document.getElementById("scaleClosePreview").value,10))*250;
  498. cpvw_prefHandler.setPref(this.prefHidePreviewDelay,_5c);
  499. var _5d=cpvw_get("cpvw_quicksearch_show").selected;
  500. cpvw_prefHandler.setPref(this.prefSubsearchBar,_5d);
  501. var _5e=document.getElementById("cooliris_previewOpenMode").value;
  502. cpvw_prefHandler.setPref(this.prefPreviewOpenMode,_5e);
  503. var _5f=cpvw_get("cpvw_theme").selectedIndex==0?"default":"white";
  504. cpvw_prefHandler.setPref(this.prefTheme,_5f);
  505. cpvw_contextSitesTreeView.saveContextSites();
  506. var _60=[];
  507. var _61=cpvw_contextSitesTreeView.arrSites.concat(cpvw_contextSitesTreeViewSelected.arrSites);
  508. for(var i=0;i<_61.length;i++){
  509. var key=_61[i];
  510. if(cpvw_contextSitesTreeView.arrCMenuItems[key]==null){
  511. continue;
  512. }
  513. if(cpvw_contextSitesTreeView.arrCMenuItems[key].selected.toString()=="true"){
  514. _60.push(key);
  515. }
  516. }
  517. cpvw_prefHandler.setPref(cpvw_Prefs.prefCMenuItems,_60.join(","));
  518. window.close();
  519. },doOK:function(){
  520. var _64=document.getElementById("cooliris_prefetchWebsites").checked;
  521. if(_64){
  522. cpvw_prefHandler.setPref(this.prefPreviewPrefetch,"yes");
  523. }else{
  524. cpvw_prefHandler.setPref(this.prefPreviewPrefetch,"no");
  525. }
  526. var _65=document.getElementById("cooliris_globalDisable").checked;
  527. if(_65){
  528. cpvw_prefHandler.setPref(this.prefPreviewEnable,"no");
  529. }else{
  530. cpvw_prefHandler.setPref(this.prefPreviewEnable,"yes");
  531. }
  532. var _66=document.getElementById("cooliris_defaultEnable").checked;
  533. if(_66){
  534. cpvw_prefHandler.setPref(this.prefPreviewDefaultEnable,"yes");
  535. }else{
  536. cpvw_prefHandler.setPref(this.prefPreviewDefaultEnable,"no");
  537. }
  538. var _67=document.getElementById("cooliris_fixedLoc").checked;
  539. if(_67){
  540. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewFixedLoc,"no");
  541. }else{
  542. cpvw_prefHandler.setPref(cpvw_Prefs.prefPreviewFixedLoc,"yes");
  543. }
  544. var _68=document.getElementById("cooliris_fixedIcon").checked;
  545. if(_68){
  546. cpvw_prefHandler.setPref(cpvw_Prefs.prefFixedIcon,true);
  547. }else{
  548. cpvw_prefHandler.setPref(cpvw_Prefs.prefFixedIcon,false);
  549. }
  550. var _69=document.getElementById("cooliris_openDelay").value;
  551. if(isNaN(_69)){
  552. alert("Enter a valid number...");
  553. return false;
  554. }else{
  555. cpvw_prefHandler.setPref(this.prefPreviewOpenDelay,_69);
  556. }
  557. var _6a=document.getElementById("cooliris_smallDivDelay").value;
  558. if(isNaN(_6a)){
  559. alert("Enter a valid number...");
  560. return false;
  561. }else{
  562. cpvw_prefHandler.setPref(this.prefMouseIconDelay,_6a);
  563. }
  564. var _6b=document.getElementById("cooliris_hidePreviewDelay").value;
  565. if(isNaN(_6b)){
  566. alert("Enter a valid number...");
  567. return false;
  568. }else{
  569. cpvw_prefHandler.setPref(this.prefHidePreviewDelay,_6b);
  570. }
  571. var _6c=cpvw_get("cooliris_subsearchBar").checked;
  572. cpvw_prefHandler.setPref(this.prefSubsearchBar,_6c);
  573. var _6d=document.getElementById("cooliris_previewOpenMode").value;
  574. cpvw_prefHandler.setPref(this.prefPreviewOpenMode,_6d);
  575. var _6e=cpvw_get("cpvw_theme").selectedIndex==0?"default":"white";
  576. cpvw_prefHandler.setPref(this.prefTheme,_6e);
  577. cpvw_contextSitesTreeView.saveContextSites();
  578. var _6f=[];
  579. var _70=cpvw_contextSitesTreeView.arrSites.concat(cpvw_contextSitesTreeViewSelected.arrSites);
  580. for(var i=0;i<_70.length;i++){
  581. var key=_70[i];
  582. if(cpvw_contextSitesTreeView.arrCMenuItems[key]==null){
  583. continue;
  584. }
  585. if(cpvw_contextSitesTreeView.arrCMenuItems[key].selected.toString()=="true"){
  586. _6f.push(key);
  587. }
  588. }
  589. cpvw_prefHandler.setPref(cpvw_Prefs.prefCMenuItems,_6f.join(","));
  590. window.close();
  591. },doCancel:function(){
  592. window.close();
  593. },getUserInfo:function(){
  594. var _73=cpvw_prefHandler.getPref(this.prefPreviewUserEmail);
  595. if(_73!=""){
  596. var _74="chrome://cooliris/";
  597. var _75="Registration";
  598. var pwd;
  599. if("@mozilla.org/passwordmanager;1" in Components.classes){
  600. var _77=Components.classes["@mozilla.org/passwordmanager;1"].createInstance(Components.interfaces.nsIPasswordManagerInternal);
  601. var _78={value:""};
  602. var _79={value:""};
  603. var _7a={value:""};
  604. try{
  605. _77.findPasswordEntry(_74,_73,"",_78,_79,_7a);
  606. }
  607. catch(e){
  608. }
  609. if(_7a.value==""){
  610. alert("Error pulling account information!");
  611. return false;
  612. }
  613. return [_73,_7a.value];
  614. }else{
  615. if("@mozilla.org/login-manager;1" in Components.classes){
  616. try{
  617. var _7b=Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
  618. var _7c=_7b.findLogins({},_74,null,_75);
  619. for(var i=0;i<_7c.length;i++){
  620. if(_7c[i].username==_73){
  621. pwd=_7c[i].password;
  622. break;
  623. }
  624. }
  625. return [_73,pwd];
  626. }
  627. catch(ex){
  628. }
  629. }
  630. }
  631. }else{
  632. return ["",""];
  633. }
  634. },setUserEmail:function(_7e,_7f){
  635. var _80="chrome://cooliris/";
  636. var _81="Registration";
  637. if("@mozilla.org/passwordmanager;1" in Components.classes){
  638. var _82=Components.classes["@mozilla.org/passwordmanager;1"].createInstance();
  639. if(_82){
  640. _82=_82.QueryInterface(Components.interfaces.nsIPasswordManager);
  641. try{
  642. _82.removeUser(_80,_7e);
  643. }
  644. catch(ex){
  645. }
  646. _82.addUser(_80,_7e,_7f);
  647. }
  648. }else{
  649. if("@mozilla.org/login-manager;1" in Components.classes){
  650. var _83=Components.classes["@mozilla.org/login-manager;1"].getService(Components.interfaces.nsILoginManager);
  651. var _84=new Components.Constructor("@mozilla.org/login-manager/loginInfo;1",Components.interfaces.nsILoginInfo,"init");
  652. var _85=new _84(_80,null,_81,username,password,"","");
  653. _83.addLogin(_85);
  654. }
  655. }
  656. cpvw_prefHandler.setPref(this.prefPreviewUserEmail,_7e);
  657. }};
  658. }
  659. if(typeof cpvw_prefHandler=="undefined"){
  660. var cpvw_prefHandler={prefs:Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch),isExists:function(_86){
  661. var _87=this.prefs.getPrefType(_86);
  662. if(_87==Components.interfaces.nsIPrefBranch.PREF_INVALID){
  663. return false;
  664. }else{
  665. if(_87==Components.interfaces.nsIPrefBranch.PREF_STRING&&cpvw_jsUtils.trimWhitespace(this.prefs.getCharPref(_86).toString())==""){
  666. return false;
  667. }
  668. }
  669. return true;
  670. },getPref:function(_88){
  671. try{
  672. var _89=this.prefs.getPrefType(_88);
  673. switch(_89){
  674. case Components.interfaces.nsIPrefBranch.PREF_STRING:
  675. return this.prefs.getCharPref(_88).toString();
  676. case Components.interfaces.nsIPrefBranch.PREF_BOOL:
  677. return this.prefs.getBoolPref(_88);
  678. case Components.interfaces.nsIPrefBranch.PREF_INT:
  679. return this.prefs.getIntPref(_88);
  680. }
  681. }
  682. catch(ex){
  683. return null;
  684. }
  685. },setPref:function(_8a,_8b){
  686. try{
  687. var _8c=this.prefs.getPrefType(_8a);
  688. switch(_8c){
  689. case 0:
  690. if(typeof (_8b)=="string"){
  691. this.prefs.setCharPref(_8a,_8b);
  692. }else{
  693. if(typeof (_8b)=="number"){
  694. this.prefs.setIntPref(_8a,_8b);
  695. }else{
  696. if(typeof (_8b)=="boolean"){
  697. this.prefs.setBoolPref(_8a,_8b);
  698. }
  699. }
  700. }
  701. break;
  702. case Components.interfaces.nsIPrefBranch.PREF_STRING:
  703. this.prefs.setCharPref(_8a,_8b);
  704. break;
  705. case Components.interfaces.nsIPrefBranch.PREF_BOOL:
  706. this.prefs.setBoolPref(_8a,_8b);
  707. break;
  708. case Components.interfaces.nsIPrefBranch.PREF_INT:
  709. this.prefs.setIntPref(_8a,_8b);
  710. break;
  711. }
  712. }
  713. catch(ex){
  714. return null;
  715. }
  716. },getPrefJson:function(_8d){
  717. try{
  718. var _8e=this.prefs.getCharPref(_8d).toString();
  719. return cpvw_jsUtils.decodeJson(_8e);
  720. }
  721. catch(ex){
  722. return null;
  723. }
  724. },setPrefJson:function(_8f,obj){
  725. try{
  726. var _91=cpvw_jsUtils.encodeJson(obj);
  727. this.prefs.setCharPref(_8f,_91);
  728. }
  729. catch(ex){
  730. return null;
  731. }
  732. },setPrefIfNotExists:function(_92,_93){
  733. var _94=this.prefs;
  734. try{
  735. if(!this.isExists(_92)){
  736. var _95=typeof (_93);
  737. switch(_95){
  738. case "string":
  739. this.prefs.setCharPref(_92,_93);
  740. break;
  741. case "boolean":
  742. this.prefs.setBoolPref(_92,_93);
  743. break;
  744. case "number":
  745. this.prefs.setIntPref(_92,_93);
  746. break;
  747. }
  748. }
  749. }
  750. catch(ex){
  751. conDump(ex+", "+_92+"."+_93);
  752. }
  753. },getComplexValue:function(_96,_97){
  754. return this.prefs.getComplexValue(_96,_97);
  755. },setComplexValue:function(_98,_99,_9a){
  756. this.prefs.setComplexValue(_98,_99,_9a);
  757. },removeAllPrefs:function(){
  758. this.prefs.deleteBranch("preview.");
  759. }};
  760. }
  761. if(typeof cpvw_jsUtils=="undefined"){
  762. var cpvw_jsUtils={setPosition:function(obj,_9c,top,_9e,_9f,_a0){
  763. if(typeof obj=="string"){
  764. obj=document.getElementById(obj);
  765. }
  766. var str="";
  767. if(_9c){
  768. str+="left:"+_9c+"px;";
  769. }
  770. if(top){
  771. str+="top:"+top+"px;";
  772. }
  773. if(_9e){
  774. str+="width:"+_9e+"px;";
  775. }
  776. if(_9f){
  777. str+="height:"+_9f+"px;";
  778. }
  779. if(obj){
  780. if(_a0){
  781. if(_9c){
  782. obj.style.left=_9c+"px";
  783. }
  784. if(top){
  785. obj.style.top=top+"px";
  786. }
  787. if(_9e){
  788. obj.style.width=_9e+"px";
  789. }
  790. if(_9f){
  791. obj.style.height=_9f+"px";
  792. }
  793. }else{
  794. obj.setAttribute("style",str);
  795. }
  796. }
  797. },isFF2:function(){
  798. var _a2=Components.classes["@mozilla.org/xre/app-info;1"].getService(Components.interfaces.nsIXULAppInfo);
  799. var _a3=Components.classes["@mozilla.org/xpcom/version-comparator;1"].getService(Components.interfaces.nsIVersionComparator);
  800. return (_a3.compare(_a2.version,"3.0")<0);
  801. },SetLocalSystemPath:function(_a4){
  802. var _a5=Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("Home",Components.interfaces.nsIFile);
  803. _a4=(_a5.path.search(/\\/)!=-1)?_a4.replace(/\//gi,"\\"):_a4.replace(/\\\\/gi,"/");
  804. return _a4;
  805. },getWorkingFolder:function(){
  806. var _a6;
  807. try{
  808. _a6=Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD",Components.interfaces.nsIFile);
  809. }
  810. catch(ex){
  811. alert(ex);
  812. }
  813. return _a6;
  814. },stringFormat:function(){
  815. var _a7=arguments.length-1;
  816. var str=arguments[0];
  817. for(var i=0;i<_a7;i++){
  818. str=str.replace("{"+i+"}",arguments[i+1],"gi");
  819. }
  820. return str;
  821. },decodeJson:function(_aa){
  822. try{
  823. var obj;
  824. if(cpvw_jsUtils.isFF2()){
  825. obj=cpvw_JSON.fromString(_aa);
  826. }else{
  827. var _ac=Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
  828. obj=_ac.decode(_aa);
  829. }
  830. return obj;
  831. }
  832. catch(ex){
  833. return null;
  834. }
  835. },encodeJson:function(obj){
  836. try{
  837. var _ae;
  838. if(cpvw_jsUtils.isFF2()){
  839. _ae=cpvw_JSON.toString(obj);
  840. }else{
  841. var _af=Components.classes["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
  842. _ae=_af.encode(obj);
  843. }
  844. return _ae;
  845. }
  846. catch(ex){
  847. return null;
  848. }
  849. },trimWhitespace:function(str){
  850. return str.replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1");
  851. },hasCooliris:function(){
  852. return (Components.classes["@cooliris.com/piclens/manager;1"]==null)?false:true;
  853. },showPiclensLite:function(_b1,_b2,_b3,_b4,_b5){
  854. var _b6="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"+"<rss version=\"2.0\" xmlns:media=\"http://search.yahoo.com/mrss\">"+"<channel>"+"<slideShowDefaults maxScale=\"2.0\" overlayToolBars=\"false\"/>"+"<generator>piclens previews 2.7</generator>"+"<title>"+_b2+"</title>"+"<link>"+_b3+"</link>"+"<description></description>";
  855. var uri=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  856. for(var i=0;i<_b4.length;i++){
  857. uri.spec=_b4[i].src;
  858. _b6+="<item>"+"<title>"+"CoolPreviews"+"</title>"+"<link>"+escape(_b4[i].src)+"</link>"+"<media:thumbnail url=\""+escape(_b4[i].thumbnailSrc)+"\"/>"+"<media:content url=\""+escape(_b4[i].src)+"\" type=\"image/jpeg\"/>"+"</item>";
  859. }
  860. _b6+=" </channel>"+"</rss>";
  861. if(_b1.wrappedJSObject.PicLensLite!=null){
  862. if(_b5){
  863. cpvw_imageDocHandler.hideTimer=1;
  864. cpvw_imageDocHandler.hidePreview();
  865. }else{
  866. cpvw_docHandler.hideTimer=1;
  867. cpvw_docHandler.hidePreview();
  868. }
  869. _b1.wrappedJSObject.PicLensLite.start({feedData:_b6,homePageLabel:_b2});
  870. }
  871. }};
  872. }
  873. var cpvw_contextSitesTreeView={treeBox:null,selection:null,arrSites:[],arrCMenuItems:null,jsContextSiteFile:"CoolirisPreviewContextSites.js",getRowCount:function(){
  874. this.rowCount=this.arrSites.length;
  875. return this.arrSites.length;
  876. },setTree:function(_b9){
  877. this.treeBox=_b9;
  878. },getCellText:function(idx,_bb){
  879. if(idx>=this.getRowCount()){
  880. return "";
  881. }
  882. if(_bb.id=="cooliris_contextSiteTree_name"){
  883. return cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[idx]].label;
  884. }
  885. },getCellValue:function(idx,_bd){
  886. if(idx>=this.getRowCount()){
  887. return "";
  888. }
  889. if(_bd.id=="cooliris_contextSiteTree_selected"){
  890. return cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[idx]].selected;
  891. }
  892. },setCellValue:function(idx,_bf,_c0){
  893. if(idx>=this.getRowCount()){
  894. return "";
  895. }
  896. if(_bf.id=="cooliris_contextSiteTree_selected"){
  897. cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[idx]].selected=_c0;
  898. }
  899. },isEditable:function(idx,_c2){
  900. return true;
  901. },isContainer:function(idx){
  902. return false;
  903. },isSeparator:function(idx){
  904. return false;
  905. },isSorted:function(){
  906. return false;
  907. },getImageSrc:function(idx,_c6){
  908. if(_c6.id=="cooliris_contextSiteTree_name"){
  909. return cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[idx]].image;
  910. }
  911. },getProgressMode:function(idx,_c8){
  912. },cycleHeader:function(col){
  913. },selectionChanged:function(){
  914. },cycleCell:function(idx,_cb){
  915. },performAction:function(_cc){
  916. },performActionOnCell:function(_cd,_ce,_cf){
  917. },getRowProperties:function(idx,_d1,_d2){
  918. },getCellProperties:function(idx,_d4,_d5){
  919. },getColumnProperties:function(_d6,_d7,_d8){
  920. },getLevel:function(idx){
  921. return 0;
  922. },invalidateTree:function(_da,_db){
  923. this.treeBox.rowCountChanged(_da,_db);
  924. },getUrl:function(_dc,_dd){
  925. var _de="";
  926. var _df=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  927. var _e0=_df.split(",");
  928. if(cpvw_jsUtils.trimWhitespace(_e0[_dc].toString())=="wiki"){
  929. _dd=_dd.replace(/\s/,"_");
  930. }else{
  931. _dd=_dd.replace(/\s/,"+");
  932. }
  933. _de=cpvw_contextSitesTreeView.arrCMenuItems[_e0[_dc]].url;
  934. if(cpvw_jsUtils.trimWhitespace(_e0[_dc].toString())=="liveimages"){
  935. _de=_de.replace("?q=cool","?q=$");
  936. }
  937. conDump("slect str "+_de,true);
  938. _de=_de.replace(/\$/gi,_dd);
  939. return _de;
  940. },selectWebsites:function(){
  941. var _e1=new Object();
  942. var end=new Object();
  943. var _e3=cpvw_contextSitesTreeView.selection.getRangeCount();
  944. var _e4=cpvw_contextSitesTreeView.getRowCount();
  945. var _e5=cpvw_contextSitesTreeViewSelected.getRowCount();
  946. var _e6=[];
  947. for(var t=0;t<_e3;t++){
  948. cpvw_contextSitesTreeView.selection.getRangeAt(t,_e1,end);
  949. for(var v=_e1.value;v<=end.value;v++){
  950. var _e9=cpvw_contextSitesTreeView.arrSites[v];
  951. cpvw_contextSitesTreeViewSelected.arrSites.push(_e9);
  952. cpvw_contextSitesTreeView.arrCMenuItems[_e9].selected=true;
  953. _e6.push(v);
  954. }
  955. }
  956. for(var i=0;i<_e6.length;i++){
  957. cpvw_contextSitesTreeView.arrSites.splice(_e6[i]-i,1);
  958. }
  959. cpvw_contextSitesTreeView.treeBox.rowCountChanged(0,-_e4);
  960. cpvw_contextSitesTreeView.treeBox.rowCountChanged(0,cpvw_contextSitesTreeView.getRowCount());
  961. cpvw_contextSitesTreeViewSelected.treeBox.rowCountChanged(0,-_e5);
  962. cpvw_contextSitesTreeViewSelected.treeBox.rowCountChanged(0,cpvw_contextSitesTreeViewSelected.getRowCount());
  963. this.clearDetails();
  964. },deselectWebsites:function(){
  965. var _eb=new Object();
  966. var end=new Object();
  967. var _ed=cpvw_contextSitesTreeViewSelected.selection.getRangeCount();
  968. var _ee=cpvw_contextSitesTreeView.getRowCount();
  969. var _ef=cpvw_contextSitesTreeViewSelected.getRowCount();
  970. var _f0=[];
  971. for(var t=0;t<_ed;t++){
  972. cpvw_contextSitesTreeViewSelected.selection.getRangeAt(t,_eb,end);
  973. for(var v=_eb.value;v<=end.value;v++){
  974. var _f3=cpvw_contextSitesTreeViewSelected.arrSites[v];
  975. cpvw_contextSitesTreeView.arrCMenuItems[_f3].selected=false;
  976. cpvw_contextSitesTreeView.arrSites.push(_f3);
  977. _f0.push(v);
  978. }
  979. }
  980. for(var i=0;i<_f0.length;i++){
  981. cpvw_contextSitesTreeViewSelected.arrSites.splice(_f0[i]-i,1);
  982. }
  983. cpvw_contextSitesTreeView.arrSites.sort();
  984. cpvw_contextSitesTreeView.treeBox.rowCountChanged(0,-_ee);
  985. cpvw_contextSitesTreeView.treeBox.rowCountChanged(0,cpvw_contextSitesTreeView.getRowCount());
  986. cpvw_contextSitesTreeViewSelected.treeBox.rowCountChanged(0,-_ef);
  987. cpvw_contextSitesTreeViewSelected.treeBox.rowCountChanged(0,cpvw_contextSitesTreeViewSelected.getRowCount());
  988. this.clearDetails();
  989. },addWebsite:function(){
  990. var _f5=cpvw_get("siteName").value;
  991. var _f6=_f5.replace(/[\s|\'|\"]/gim,"");
  992. _f5=_f5.replace(/[\'|\"]/gim,"");
  993. var _f7=cpvw_get("siteUrl").value;
  994. _f7=_f7.replace(/[\'|\"]/gim,"");
  995. var _f8=this.getFaviconUrl(cpvw_get("siteUrl").value);
  996. _f8=_f8.replace(/[\'|\"]/gim,"");
  997. _f5=cpvw_jsUtils.trimWhitespace(_f5);
  998. if(cpvw_jsUtils.trimWhitespace(_f5)==""){
  999. alert("Please enter a site name!");
  1000. return;
  1001. }
  1002. var _f9=cpvw_contextSitesTreeView.arrSites.concat(cpvw_contextSitesTreeViewSelected.arrSites);
  1003. var _fa=[];
  1004. for(var i=0;i<_f9.length;i++){
  1005. _fa.push(cpvw_contextSitesTreeView.arrCMenuItems[_f9[i]].label);
  1006. }
  1007. if(_fa.indexOf(_f5)!=-1){
  1008. alert("Same name already exists!");
  1009. return;
  1010. }
  1011. var _fc="cool";
  1012. if(_fc!=""){
  1013. _f7=_f7.replace(new RegExp(_fc,"gim"),"$");
  1014. }
  1015. cpvw_contextSitesTreeViewSelected.treeBox.rowCountChanged(0,-cpvw_contextSitesTreeViewSelected.getRowCount());
  1016. cpvw_contextSitesTreeViewSelected.arrSites.unshift(_f6);
  1017. cpvw_contextSitesTreeView.arrCMenuItems[_f6]=[];
  1018. cpvw_contextSitesTreeView.arrCMenuItems[_f6].label=_f5;
  1019. cpvw_contextSitesTreeView.arrCMenuItems[_f6].url=_f7;
  1020. cpvw_contextSitesTreeView.arrCMenuItems[_f6].image=_f8;
  1021. cpvw_contextSitesTreeView.arrCMenuItems[_f6].selected=true;
  1022. cpvw_contextSitesTreeViewSelected.treeBox.rowCountChanged(0,cpvw_contextSitesTreeViewSelected.getRowCount());
  1023. this.clearDetails();
  1024. },editWebsite:function(){
  1025. var _fd=this.selection.currentIndex;
  1026. if(_fd==-1){
  1027. return;
  1028. }
  1029. if(cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[_fd]]==null){
  1030. return;
  1031. }
  1032. cpvw_get("siteName").value=cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[_fd]].label;
  1033. cpvw_get("siteUrl").value=cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[_fd]].url;
  1034. },removeWebsite:function(){
  1035. var _fe=this.selection.currentIndex;
  1036. if(_fe==-1){
  1037. return;
  1038. }
  1039. var _ff=this.getRowCount();
  1040. this.treeBox.rowCountChanged(0,-_ff);
  1041. cpvw_contextSitesTreeView.arrCMenuItems[this.arrSites[_fe]]=null;
  1042. this.arrSites.splice(_fe,1);
  1043. this.treeBox.rowCountChanged(0,this.getRowCount());
  1044. this.clearDetails();
  1045. },getFaviconUrl:function(link){
  1046. try{
  1047. var uri=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
  1048. uri.spec=link;
  1049. return uri.scheme+"://"+uri.host+"/favicon.ico";
  1050. }
  1051. catch(ex){
  1052. return "";
  1053. }
  1054. },clearDetails:function(){
  1055. cpvw_get("siteName").value="";
  1056. cpvw_get("siteUrl").value="http://";
  1057. },loadContextSites:function(_102,_103){
  1058. try{
  1059. var _104=cpvw_jsUtils.getWorkingFolder();
  1060. _104.append(this.jsContextSiteFile);
  1061. var _105;
  1062. if(!_104.exists()||_102){
  1063. _105="chrome://cooliris/content/CoolirisPreviewContextSites.js";
  1064. }else{
  1065. _105="file:///"+_104.path;
  1066. }
  1067. var req=new XMLHttpRequest();
  1068. req.open("GET",_105,false);
  1069. req.send(null);
  1070. var _107=req.responseText;
  1071. try{
  1072. if(_103){
  1073. this.arrCMenuItems=eval("("+_107+")");
  1074. }else{
  1075. this.arrCMenuItems=cpvw_jsUtils.decodeJson(_107);
  1076. }
  1077. var _108=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  1078. _108=","+_108+",";
  1079. for(var key in this.arrCMenuItems){
  1080. conDump(key+" =-= "+this.arrCMenuItems[key].label);
  1081. if(_108.indexOf(","+key+",")!=-1){
  1082. cpvw_contextSitesTreeViewSelected.arrSites.push(key);
  1083. cpvw_contextSitesTreeView.arrCMenuItems[key].selected=true;
  1084. }else{
  1085. cpvw_contextSitesTreeView.arrSites.push(key);
  1086. cpvw_contextSitesTreeView.arrCMenuItems[key].selected=false;
  1087. }
  1088. }
  1089. cpvw_contextSitesTreeViewSelected.arrSites.sort(function(a,b){
  1090. if(_108.indexOf(a)<_108.indexOf(b)){
  1091. return -1;
  1092. }else{
  1093. if(_108.indexOf(a)>_108.indexOf(b)){
  1094. return 1;
  1095. }
  1096. }
  1097. return 0;
  1098. });
  1099. cpvw_contextSitesTreeView.arrSites.sort();
  1100. }
  1101. catch(ex){
  1102. }
  1103. }
  1104. catch(ex){
  1105. alert(ex);
  1106. }
  1107. },serializeJS:function(){
  1108. var data="";
  1109. var i=0;
  1110. var _10e=cpvw_contextSitesTreeView.arrSites.concat(cpvw_contextSitesTreeViewSelected.arrSites);
  1111. var _10f={};
  1112. for(var i=0;i<_10e.length;i++){
  1113. var key=_10e[i];
  1114. if(cpvw_contextSitesTreeView.arrCMenuItems[key]==null){
  1115. continue;
  1116. }
  1117. _10f[key]={label:cpvw_contextSitesTreeView.arrCMenuItems[key].label,url:cpvw_contextSitesTreeView.arrCMenuItems[key].url,image:cpvw_contextSitesTreeView.arrCMenuItems[key].image};
  1118. }
  1119. data=cpvw_jsUtils.encodeJson(_10f);
  1120. return data;
  1121. },saveContextSites:function(){
  1122. try{
  1123. var data=this.serializeJS();
  1124. var _112=Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
  1125. var _113=cpvw_jsUtils.getWorkingFolder();
  1126. _113.append(this.jsContextSiteFile);
  1127. _112.init(_113,2|8|32,436,0);
  1128. _112.write(data,data.length);
  1129. _112.close();
  1130. return true;
  1131. }
  1132. catch(ex){
  1133. alert(ex);
  1134. return false;
  1135. }
  1136. },openHelp:function(){
  1137. var wm=Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
  1138. var win=wm.getMostRecentWindow("navigator:browser");
  1139. if(win!=null){
  1140. win.getBrowser().selectedTab=win.getBrowser().addTab("http://www.coolpreviews.com/client/links/rightclicksearch.html");
  1141. }
  1142. }};
  1143. var cpvw_contextSitesTreeViewSelected={treeBox:null,selection:null,arrSites:[],arrCMenuItems:null,jsContextSiteFile:"CoolirisPreviewContextSites.js",getRowCount:function(){
  1144. this.rowCount=this.arrSites.length;
  1145. return this.arrSites.length;
  1146. },setTree:function(_116){
  1147. this.treeBox=_116;
  1148. },getCellText:function(idx,_118){
  1149. if(idx>=this.getRowCount()){
  1150. return "";
  1151. }
  1152. if(_118.id=="cooliris_contextSiteTree_name"){
  1153. return cpvw_contextSitesTreeView.arrCMenuItems[cpvw_contextSitesTreeViewSelected.arrSites[idx]].label;
  1154. }
  1155. },getCellValue:function(idx,_11a){
  1156. if(idx>=this.getRowCount()){
  1157. return "";
  1158. }
  1159. },setCellValue:function(idx,_11c,_11d){
  1160. if(idx>=this.getRowCount()){
  1161. return "";
  1162. }
  1163. },isEditable:function(idx,_11f){
  1164. return true;
  1165. },isContainer:function(idx){
  1166. return false;
  1167. },isSeparator:function(idx){
  1168. return false;
  1169. },isSorted:function(){
  1170. return false;
  1171. },getImageSrc:function(idx,_123){
  1172. if(_123.id=="cooliris_contextSiteTree_name"){
  1173. return cpvw_contextSitesTreeView.arrCMenuItems[cpvw_contextSitesTreeViewSelected.arrSites[idx]].image;
  1174. }
  1175. },getProgressMode:function(idx,_125){
  1176. },cycleHeader:function(col){
  1177. },selectionChanged:function(){
  1178. },cycleCell:function(idx,_128){
  1179. },performAction:function(_129){
  1180. },performActionOnCell:function(_12a,_12b,_12c){
  1181. },getRowProperties:function(idx,_12e,prop){
  1182. },getCellProperties:function(idx,_131,prop){
  1183. },getColumnProperties:function(_133,_134,prop){
  1184. },getLevel:function(idx){
  1185. return 0;
  1186. },invalidateTree:function(_137,_138){
  1187. this.treeBox.rowCountChanged(_137,_138);
  1188. }};
  1189. function cpvw_get(_139,doc){
  1190. if(doc==null){
  1191. return document.getElementById(_139);
  1192. }else{
  1193. return doc.getElementById(_139);
  1194. }
  1195. }
  1196. function conDump(_13b,_13c){
  1197. if(cpvw_prefHandler.getPref(cpvw_Prefs.prefPreviewDebug)=="no"&&!_13c){
  1198. return;
  1199. }
  1200. var _13d=Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
  1201. _13d.logStringMessage("cooliris: "+_13b);
  1202. }
  1203.  
  1204.